#include <chrono>

#include "rclcpp/rclcpp.hpp"

using namespace std::literals::chrono_literals;

class ParamLogNode : public rclcpp::Node
{
public:
    ParamLogNode(std::string name) : Node(name)
    {
        RCLCPP_INFO(this->get_logger(), "I am %s", name.c_str());
        this->declare_parameter("log_level", 0);
        this->declare_parameter("test_para", "li");
        this->declare_parameter("yaml_file_path", "");

        timer_ = this->create_wall_timer(1000ms, std::bind(&ParamLogNode::_timer_callback, this));
    }

private:
    void _timer_callback()
    {
        this->get_parameter("log_level", log_level_);
        this->get_parameter("test_para", test_para_);
        this->get_parameter("yaml_file_path", file_path_);
        std::cout << "==============log_level===============" << log_level_ << "================================" << std::endl;
        std::cout << "==============test_para===============" << test_para_ << "================================" << std::endl;
        std::cout << "==============yaml_file_path===============" << file_path_ << "================================" << std::endl;
    }

private:
    int log_level_{0};
    std::string test_para_{};
    std::string file_path_;
    rclcpp::TimerBase::SharedPtr timer_{};
};

int main(int argc, char **argv)
{
    if (argc > 0)
    {
        for (int i = 0; i < argc; ++i)
        {
            RCLCPP_INFO(rclcpp::get_logger(""), "arg%d: %s", i, argv[i]);
        }
    }
    rclcpp::init(argc, argv);
    auto node = std::make_shared<ParamLogNode>("param_log_arg_par");
    rclcpp::spin(node);
    rclcpp::shutdown();

    return 0;
}